package com.actionsky.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.actionsky.dao.SearchDAO;
import com.actionsky.entity.Article;

public class ShowArticle extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
	private Article article = null;
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		int id = Integer.parseInt(request.getParameter("id"));	//获取文章id
		article = SearchDAO.findArticleById(id);
		request.getSession().setAttribute("show_article", article);
		response.sendRedirect("search/showArticle.jsp");
	}

	public void init() throws ServletException {
	}
	public void destroy() {
		super.destroy(); 
	}

}
